﻿using Base.HrExtendService;
using Basic.HrCollect;
using Basic.HrModel.DB;
using Basic.HrRemoteModel.EmpFile.Model;
using Basic.HrService.Interface;

namespace Basic.HrService.lmpl
{
    internal class EmpSelfFileService : IEmpSelfFileService
    {
        private readonly IEmpSelfFileCollect _Service;
        private readonly IFileService _File;

        public EmpSelfFileService ( IEmpSelfFileCollect service, IFileService file )
        {
            this._Service = service;
            this._File = file;
        }
        public long Add ( EmpSelfFileAdd add )
        {
            long id = this._Service.Add(add);
            this._File.Save(add.FileId, id);
            return id;
        }

        public void Delete ( long id )
        {
            DBEmpSelfFileList file = this._Service.Get(id);
            this._Service.Delete(file);
            this._File.Drop(file.FileId);
        }

        public EmpFileDto FindLast ( long empId, string classtify )
        {
            return this._Service.FindLast<EmpFileDto>(empId, classtify);
        }
        public EmpFileDto[] Gets ( long empId, string classtify )
        {
            return this._Service.Gets<EmpFileDto>(empId, classtify);
        }
    }
}
